import React, {PureComponent, Fragment} from 'react';
import './App.css';
import {InputNumber, Input,Modal} from 'antd';
import 'antd/dist/antd.css';
import padStart from 'lodash/padStart'
// const fs = window.electron.remote.require('fs')

// const {ipcRenderer} = window.electron;
const { ipcRenderer } = window.require('electron');
const { fs } = window.require('electron');
// const {BrowserWindow} =window.electron.remote


class App extends PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            coms: [],
            com: '',
            set: {},
            setting: {
                version: '',
            },
            read1:"",
            read2_1:"",
            read2_2:"",
            read2_3:"",
            read4:"",
            read5:"",
        };
    }
    paddingZero=(num, length) =>{
        for(let len = (num + "").length; len < length; len = num.length) {
            num = "0" + num;
        }
        return num;
    }
    componentDidMount() {
        console.log('ipcRenderer', ipcRenderer)
        const that = this;
        ipcRenderer.send('getVersion');
        ipcRenderer.send('getCOMs');
        ipcRenderer.on('getVersionFromMain', (event, version) => {
            console.log('version', version)
            that.setState({
                version: version
            })
        });
        ipcRenderer.on('getCOMsFromMain', (event, coms) => {
            console.log('coms', coms)
            that.setState({
                coms: coms
            })
        });

        ipcRenderer.on('consoleFromMain', (event, msg) => {
            console.log(msg)
        });
        ipcRenderer.on('getBaseInfoFromMain', (event, data) => {
            console.log('data', data)

            const imeiArr = data.slice(8, 16);
            const imsiArr = data.slice(16, 24)
            let imei = '';
            let imsi = '';

            for (let i = 0; i < imeiArr.length; i++) {
                const to16 = imeiArr[i].toString(16);
                const to16_1 = to16.slice(0, 2);
                const to16_2 = to16.slice(-2);
                imei += that.hexCharCodeToStr(to16_1)
                imei += that.hexCharCodeToStr(to16_2)
            }
            for (let i = 0; i < imsiArr.length; i++) {
                const to16 = imsiArr[i].toString(16);
                const to16_1 = to16.slice(0, 2);
                const to16_2 = to16.slice(-2);
                imsi += that.hexCharCodeToStr(to16_1)
                imsi += that.hexCharCodeToStr(to16_2)
            }
            console.log('imei', imei.length)
            that.setState({
                read1: that.paddingZero(that.combineUint32(data[0], data[1]),10),
                read2_1: (data[2] >> 8).toString(16),// (#1 << 8) | (#2 & 0xFF)
                read2_2: (data[2] & 0xFF).toString(16), //
                read2_3: padStart(data[3].toString(16),4,'0'), // #3
                read3: that.combineUint64(data[4], data[5], data[6], data[7]),
                read4: imei.substr(0, 15),
                read5: imsi.substr(0, 15),
            })
        })
        ipcRenderer.on('getOTAInfoFromMain', (event, data) => {
            console.log('data', data)
            const otaServerArr = data.slice(0, 64);
            let otaServer = '';
            for (let i = 0; i < otaServerArr.length; i++) {
                const to16 = otaServerArr[i].toString(16);
                const to16_1 = to16.slice(0, 2);
                const to16_2 = to16.slice(-2);
                otaServer += that.hexCharCodeToStr(to16_1)
                otaServer += that.hexCharCodeToStr(to16_2)
            }
            that.setState({
                read21:otaServer,
                read22: data[64],
            })
        })

        ipcRenderer.on('getValveInfoFromMain', (event, data) => {
            console.log('data', data)
            that.setState({
                read23: data[0],
            })
        })

        ipcRenderer.on('getInfo1FromMain', (event, data) => {
            console.log('data', data)
            that.setState({
                read6: that.combineUint32(data[0], data[1]),
                read7: that.combineUint32(data[2], data[3]),
                read8: that.combineFloat32(data[4], data[5]).toFixed(2),
                read9: data[6],
                read10: data[7],
                read11: that.combineUint32(data[8], data[9]),
                read12: that.combineUint32(data[10], data[11]),
                read13: that.combineUint32(data[12], data[13]),
                read14: that.combineUint32(data[14], data[15]),
                read15: data[16],
                read16: data[17],
                read17: data[18],
                read18: that.combineUint32(data[19], data[20]),
                read19: that.combineUint32(data[21], data[22]),
                read20: that.combineUint32(data[23], data[24])
            })
        });
        ipcRenderer.on('rebootSuccess', (event, data) => {
            console.log('data', data)
            that.setState({
                com:'',
                read1: '',
                read2_1: '',
                read2_2: '',
                read2_3: '',
                read3: '',
                read4: '',
                read5: '',
                read6: '',
                read7: '',
                read8: '',
                read9: '',
                read10: '',
                read11: '',
                read12: '',
                read13: '',
                read14: '',
                read15: '',
                read16: '',
                read17: '',
                read18: '',
                read19: '',
                read20: ''
            })
        });
        ipcRenderer.on('exportGetFromMain', (event, res) => {
            const content = {
                PSM_Peroidic: that.state.read6,
                PSM_Active: that.state.read7,
                Request_eDRX: Number(that.state.read8),
                Onenet_Login_Timeout: that.state.read9,
                Onenet_Login_Max_Retry: that.state.read10,
                Onenet_Lifetime: that.state.read11,
                Onenet_Lifetime_over: that.state.read12,
                Onenet_Lifetime_update: that.state.read13,
                Onenet_Lifetime_update_timeout: that.state.read14,
                Onenet_Notify_timeout: that.state.read15,
                Onenet_Notify_Max_Retry: that.state.read16,
                Onenet_Notify_Failed: that.state.read17,
                Onenet_Observe: that.state.read18,
                Network_Attach_timeout: that.state.read19,
                NTP_Cycle: that.state.read20,
            }
            fs.writeFile(res, JSON.stringify(content), {'encoding ': 'utf-8'}, err => {
                if (err) {
                    console.log('err', err)
                    ipcRenderer.send('open-dialog', {
                        type: "error",
                        title: "Error",
                        message: err.toString()
                    });
                    return false
                }
                ;
                console.log('导出成功');
                ipcRenderer.send('open-dialog', {
                    type: "info",
                    title: "Success",
                    message: '导出获取值成功'
                });

            });
        })
        ipcRenderer.on('exportSetFromMain', (event, res) => {
            const content = {
                PSM_Peroidic: that.state.set.write6,
                PSM_Active: that.state.set.write7,
                Request_eDRX: that.state.set.write8,
                Onenet_Login_Timeout: that.state.set.write9,
                Onenet_Login_Max_Retry: that.state.set.write10,
                Onenet_Lifetime: that.state.set.write11,
                Onenet_Lifetime_over: that.state.set.write12,
                Onenet_Lifetime_update: that.state.set.write13,
                Onenet_Lifetime_update_timeout: that.state.set.write14,
                Onenet_Notify_timeout: that.state.set.write15,
                Onenet_Notify_Max_Retry: that.state.set.write16,
                Onenet_Notify_Failed: that.state.set.write17,
                Onenet_Observe: that.state.set.write18,
                Network_Attach_timeout: that.state.set.write19,
                NTP_Cycle: that.state.set.write20,
            }
            console.log('content', content)
            fs.writeFile(res, JSON.stringify(content), {'encoding ': 'utf-8'}, err => {
                if (err) {
                    console.log('err', err)
                    ipcRenderer.send('open-dialog', {
                        type: "error",
                        title: "Error",
                        message: err.toString()
                    });
                    return false
                }
                ;
                console.log('导出成功');
                ipcRenderer.send('open-dialog', {
                    type: "info",
                    title: "Success",
                    message: '导出设置值成功'
                });

            });
        })
        ipcRenderer.on('importSetFromMain', (event, res) => {
            console.log(res)
            const content = {
                PSM_Peroidic: that.state.set.write6,
                PSM_Active: that.state.set.write7,
                Request_eDRX: that.state.set.write8,
                Onenet_Login_Timeout: that.state.set.write9,
                Onenet_Login_Max_Retry: that.state.set.write10,
                Onenet_Lifetime: that.state.set.write11,
                Onenet_Lifetime_over: that.state.set.write12,
                Onenet_Lifetime_update: that.state.set.write13,
                Onenet_Lifetime_update_timeout: that.state.set.write14,
                Onenet_Notify_timeout: that.state.set.write15,
                Onenet_Notify_Max_Retry: that.state.set.write16,
                Onenet_Notify_Failed: that.state.set.write17,
                Onenet_Observe: that.state.set.write18,
                Network_Attach_timeout: that.state.set.write19,
                NTP_Cycle: that.state.set.write20,
            }
            fs.readFile(res, 'utf-8', function (err, data) {
                if (err) {
                    ipcRenderer.send('open-dialog', {
                        type: "error",
                        title: "Error",
                        message: err.toString()
                    });
                } else {
                    console.log(data);
                    const content = JSON.parse(data);
                    console.log('content', content)
                    for (let key in content) {
                        if (typeof (content[key]) !== 'number') {
                            console.log(`${key}非数字，请修改后重新导入`)
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}非数字，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Login_Timeout'&&(content[key]<30||content[key]>3600)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围30-3600，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Login_Max_Retry'&&(content[key]<1||content[key]>100)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围1-100，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Lifetime'&&(content[key]<30||content[key]>86400)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围30-3600，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Lifetime_over'&&(content[key]<30||content[key]>86400)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围30-3600，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Lifetime_update'&&(content[key]<30||content[key]>86400)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围30-3600，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Lifetime_update_timeout'&&(content[key]<10||content[key]>120)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围10-120，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Notify_timeout'&&(content[key]<10||content[key]>120)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围10-120，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Notify_Max_Retry'&&(content[key]<1||content[key]>100)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围1-100，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Notify_Failed'&&(content[key]<1||content[key]>100)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围1-100，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Onenet_Observe'&&(content[key]<60||content[key]>300)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围60-300，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='Network_Attach_timeout'&&(content[key]<3600||content[key]>86400)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围范围3600-86400，请修改后重新导入`
                            });
                            return;
                        }
                        if(key==='NTP_Cycle'&&(content[key]<300||content[key]>86400)){
                            ipcRenderer.send('open-dialog', {
                                type: "error",
                                title: "Error",
                                message: `${key}范围300-86400，请修改后重新导入`
                            });
                            return
                        }
                    }

                    that.setState({
                        set:{
                            write6:content.PSM_Peroidic,
                            write7:content.PSM_Active,
                            write8:content.Request_eDRX,
                            write9:content.Onenet_Login_Timeout,
                            write10:content.Onenet_Login_Max_Retry,
                            write11:content.Onenet_Lifetime,
                            write12:content.Onenet_Lifetime_over,
                            write13:content.Onenet_Lifetime_update,
                            write14:content.Onenet_Lifetime_update_timeout,
                            write15:content.Onenet_Notify_timeout,
                            write16:content.Onenet_Notify_Max_Retry,
                            write17:content.Onenet_Notify_Failed,
                            write18:content.Onenet_Observe,
                            write19:content.Network_Attach_timeout,
                            write20:content.NTP_Cycle,
                        }

                    })


                }
            });
        })

        ipcRenderer.send('getPrinterList');

    }

    trimStr = (str) => {
        return str.replace(/(^\s*)|(\s*$)/g, "");
    }
    renderUint16 = (value) => {
        const buffer = new ArrayBuffer(2);
        const ui16Buffer = new Uint16Array(buffer);
        ui16Buffer[0] = value[0];
        return ui16Buffer[0]
    }

    combineUint32 = (msb, lsb) => {
        let a = (msb & 0xFFFF) << 16 | (lsb & 0xFFFF);
        return a >>> 0;
    }

    combineUint64 = (v0, v1, v2, v3) => {
        return ((v0 & 0xFFFF) << 48) | ((v1 & 0xFFFF) << 32) | (v2 & 0xFFFF) << 16 | (v3 & 0xFFFF);
    }

    combineFloat32 = (msb, lsb) => {
        const buffer = new ArrayBuffer(4);
        const f32 = new Float32Array(buffer);
        const ui16 = new Uint16Array(buffer);
        ui16[0] = lsb;
        ui16[1] = msb;
        return f32[0];
    }
    //获取高位
    getUint32MSB = (value) => {
        let word = (value >> 16) & 0xFFFF;
        return  word;
        // return (word << 8) & 0xFF00 | (word >> 8) & 0x00FF;
    }
    //获取低位
    // getUint32LSB = (value) => {
    //     let word = value & 0xFFFF;
    //     return (word << 8) & 0xFF00 | (word >> 8) & 0x00FF;
    // }
    getUint32LSB = (value) => {
        console.log(' getUint32LSB value',value)
        let word = value & 0xFFFF;
        return word
        // return (word << 8) & 0xFF00 | (word >> 8) & 0x00FF;
    }

    //获取高位
    getFloat32MSB = (value) => {
        const buffer = new ArrayBuffer(4);
        const ui8 = new Uint8Array(buffer);
        const f32 = new Float32Array(buffer);
        f32[0] = value;
        return (ui8[2] << 8) | ui8[3];
    }
    //获取低位
    getFloat32LSB = (value) => {
        const buffer = new ArrayBuffer(4);
        const ui8 = new Uint8Array(buffer);
        const f32 = new Float32Array(buffer);
        f32[0] = value;
        return (ui8[0] << 8) | ui8[1];
    }

    hexCharCodeToStr = (hexCharCodeStr) => {
        var trimedStr = hexCharCodeStr.trim();
        var rawStr = trimedStr.substr(0, 2).toLowerCase() === "0x" ? trimedStr.substr(2) : trimedStr;
        var len = rawStr.length;
        if (len % 2 !== 0) {
            return "";
        }
        var curCharCode;
        var resultStr = [];
        for (var i = 0; i < len; i = i + 2) {
            curCharCode = parseInt(rawStr.substr(i, 2), 16);
            resultStr.push(String.fromCharCode(curCharCode));
        }
        return resultStr.join("");
    }
    getBaseInfo = () => {
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        const that = this;
        that.setState({
            read1: '',
            read2_1: '',
            read2_2: '',
            read2_3: '',
            read3: '',
            read4: '',
            read5: '',
        })
        ipcRenderer.send('getBaseInfo');
    }
    getOTAInfo=()=>{
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        const that = this;
        that.setState({
            read21: '',
            read22: '',
        })
        ipcRenderer.send('getOTAInfo');
    }
    saveOTAInfo=()=>{
        console.log('read21',this.state.read21,)
        console.log('read22',this.state.read22,)
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        if ((!this.state.read21) || (!this.state.read22)) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: "OTA Server Host和OTA Server Port不能为空"
            });
            return false
        }
        const str2buf=this.string2buffer(this.state.read21);
        console.log('str2buf',str2buf)
        const ui16 = new Uint16Array(str2buf);
        const array = new Uint16Array(65);
        for(let i=0;i<array.length;i++){
            if(ui16[i]){
                array[i]=ui16[i]
            }else if(i===64){
                array[64]= this.getUint32LSB(this.state.read22);
            }else{
                array[i]=0
            }
        }
        console.log(array)
        ipcRenderer.send('saveOTAInfo', array);
    }
    getValveInfo=()=>{
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        const that = this;
        that.setState({
            read23: '',
        })
        ipcRenderer.send('getValveInfo');
    }
    saveValveInfo=()=>{
        console.log('read23',this.state.read23,)
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        if (this.state.read23===''||this.state.read23==undefined) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: "Valve不能为空"
            });
            return false
        }
        const array = new Uint16Array(1);
        // array[0] = this.getUint32MSB(this.state.read23);
        array[0] = this.getUint32LSB(this.state.read23);

        console.log(array)
        ipcRenderer.send('saveValveInfo', array);
    }
    string2buffer = (str) => {
        console.log(`str:${str}${str.length}`)
        if(str.length%2!==0){
            str+=" "
        }
        // 首先将字符串转为16进制
        let val = ""
        for (let i = 0; i < str.length; i++) {
            if (val === '') {
                val = str.charCodeAt(i).toString(16)
            } else {
                val += ',' + str.charCodeAt(i).toString(16)
            }
        }
        // 将16进制转化为ArrayBuffer
        return new Uint8Array(val.match(/[\da-f]{2}/gi).map(function (h) {
            return parseInt(h, 16)
        })).buffer
    }
    saveBase = () => {
        console.log(this.state)
        console.log('this.state.read1',this.state.read1)
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        if ((this.state.read1 === '')) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: "Serial Number不能为空"
            });
            return false
        }
        const array = new Uint16Array(2);

        array[0] = this.getUint32MSB(this.state.read1);
        array[1] = this.getUint32LSB(this.state.read1);
        // array[2] = (this.state.read2_1 << 8) | (this.state.read2_2 & 0xFF) //(#1 << 8) | (#2 & 0xFF);
        // array[3] =  this.getUint32LSB(this.state.read2_3);
        console.log(array)
        ipcRenderer.send('saveBaseInfo', array);
    }
    getOption1 = () => {
        console.log(this.state)
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        ipcRenderer.send('getInfo1');

    }
    saveInfo = () => {
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        if (Number(this.state.set.write6) < Number(this.state.set.write7)) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: 'PSM Peroidic 必须大于等于 PSM Active'
            });
            return false
        }
        if (Number(this.state.set.write12) < Number(this.state.set.write11)) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: 'Onenet Lifetime over  必须大于 Onenet Lifetime'
            });
            return false
        }
        if (Number(this.state.set.write11) < Number(this.state.set.write13)) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: 'Onenet Lifetime  必须大于 Onenet Lifetime update'
            });
            return false
        }
        const array = new Uint16Array(25);
        array[0] = this.getUint32MSB(this.state.set.write6);
        array[1] = this.getUint32LSB(this.state.set.write6);
        array[2] = this.getUint32MSB(this.state.set.write7);
        array[3] = this.getUint32LSB(this.state.set.write7);
        array[4] = this.getFloat32MSB(this.state.set.write8);
        array[5] = this.getFloat32LSB(this.state.set.write8);
        array[6] = this.getUint32LSB(this.state.set.write9);
        array[7] = this.getUint32LSB(this.state.set.write10);
        array[8] = this.getUint32MSB(this.state.set.write11);
        array[9] = this.getUint32LSB(this.state.set.write11);
        array[10] = this.getUint32MSB(this.state.set.write12);
        array[11] = this.getUint32LSB(this.state.set.write12);
        array[12] = this.getUint32MSB(this.state.set.write13);
        array[13] = this.getUint32LSB(this.state.set.write13);
        array[14] = this.getUint32MSB(this.state.set.write14);
        array[15] = this.getUint32LSB(this.state.set.write14);
        array[16] = this.getUint32LSB(this.state.set.write15);
        array[17] = this.getUint32LSB(this.state.set.write16);
        array[18] = this.getUint32LSB(this.state.set.write17);
        array[19] = this.getUint32MSB(this.state.set.write18);
        array[20] = this.getUint32LSB(this.state.set.write18);
        array[21] = this.getUint32MSB(this.state.set.write19);
        array[22] = this.getUint32LSB(this.state.set.write19);
        array[23] = this.getUint32MSB(this.state.set.write20);
        array[24] = this.getUint32LSB(this.state.set.write20);
        console.log(array)
        ipcRenderer.send('saveInfo', array);
    }

    setStateDate = (key, e) => {
        console.log(key)
        this.setState({
            set: {
                ...this.state.set,
                [key]: e
            }
        })
    }
    reset = () => {
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        ipcRenderer.send('resetModbus');
    }
    reboot = () => {
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        ipcRenderer.send('rebootModbus');
    }
    eraseFlash = () => {
        if (!this.state.com) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: '请先选择COM口'
            });
            return false
        }
        ipcRenderer.send('eraseFlash');
    }
    exportGet = () => {
        ipcRenderer.send('exportGet');
    }
    exportSet = () => {

        ipcRenderer.send('exportSet');
    }
    importSet = () => {
        ipcRenderer.send('importSet');
    }
    print0=(type)=>{
        if(!this.state.read4){
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: 'IMEI不能为空'
            });
            return false
        }
        ipcRenderer.send('openNewModal',this.state.read4,this.state.read5,type);

    }
    printSN=()=>{
        if ((this.state.read1 === '') || (this.state.read2_1 === '') || (this.state.read2_2 === '') || (this.state.read2_3 === '')) {
            ipcRenderer.send('open-dialog', {
                type: "error",
                title: "Error",
                message: "Serial Number和Product Code不能为空"
            });
            return false
        }
        ipcRenderer.send('openSNModal',this.state.read1,this.state.read2_1,this.state.read2_2,this.state.read2_3);

    }
    render() {
        return (
            <div>
                <div className="App">
                    <div className="project-name">
                        <div>
                            广州辂轺RTU配置工具-V{this.state.version}
                        </div>
                        <div className={'select-port'}>
                            选择端口<select style={{padding: '0px 12px', width: '200px', marginLeft: '10px'}}
                                        defaultValue="" value={this.state.com} onChange={(e) => {
                            console.log(e.target.value)
                            this.setState({
                                com: e.target.value
                            })
                            ipcRenderer.send('selectCOM', e.target.value);
                        }} className="form-control" id="port">
                            <option style={{display: 'none'}}></option>
                            {
                                this.state.coms.map((item, index) => {
                                    return <option value={item.path} key={index}>{item.path}</option>
                                })
                            }
                        </select>
                        </div>
                    </div>
                    <div className="top-box">
                        <h3><img
                            src="https://www.17sucai.com/preview/860087/2018-12-17/%E5%8A%9E%E5%85%ACOA%E7%B3%BB%E7%BB%9F/images/icon01.png"
                            alt=""/>基本信息</h3>
                        <div style={{display: 'flex'}}>
                            <div>
                                <div className={'marginTop15'}>
                                    <label>Serial Number : </label>
                                    <Input style={{width: '270px'}} value={this.state.read1}
                                                 onChange={(e) => {
                                                     this.setState({
                                                         read1: e.target.value
                                                     })
                                                 }}/>
                                    <label style={{width: '120px'}}>Product Code : </label>
                                    <Input value={this.state.read2_1}  style={{width: '80px', marginRight: '5px'}}/>
                                    <Input value={this.state.read2_2} style={{width: '80px', marginRight: '5px'}}/>
                                    <Input value={this.state.read2_3}  style={{width: '100px', marginRight: '5px'}}/>
                                </div>
                                <div className={'marginTop15'}>
                                    <label style={{width: '150px'}}>IMEI : </label>
                                    <Input style={{width: '270px'}} value={this.state.read4}/>
                                    <label style={{width: '120px'}}>IMSI : </label>
                                    <Input style={{width: '270px'}} value={this.state.read5}/>
                                </div>
                                <div className={'marginTop15'}>
                                    <label style={{width: '150px'}}>Firmware Version : </label>
                                    <Input style={{width: '270px'}} value={this.state.read3}/>
                                </div>
                            </div>
                            <div style={{flex: 1, marginLeft: '10px'}}>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-success "
                                            onClick={this.getBaseInfo}>读取
                                    </button>
                                </div>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-info "
                                            onClick={this.saveBase}>设置
                                    </button>
                                </div>
                                <br/>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-warning "
                                            onClick={this.eraseFlash}>擦除外部FLASH
                                    </button>
                                </div>

                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-danger "
                                            onClick={this.reboot}>重启
                                    </button>
                                </div>
                                <br/>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-success "
                                            onClick={this.printSN}>打印SN码
                                    </button>
                                </div>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-info "
                                            // onClick={this.print0}
                                            onClick={()=>{
                                                this.setState({
                                                    printModal:true
                                                })
                                            }}
                                    >打印IMEI
                                    </button>
                                </div>
                            </div>

                        </div>

                        <div style={{display: 'flex',marginBottom:'10px'}}>
                            <div>
                                <div className={'marginTop15'}>
                                    <label style={{width: '150px'}}>Valve : </label>
                                    <Input style={{width: '270px'}} value={this.state.read23}
                                           onChange={(e) => {
                                               this.setState({
                                                   read23: e.target.value
                                               })
                                           }}/>
                                </div>
                            </div>
                            <div style={{flex: 1, marginLeft: '20px'}}>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-success "
                                            onClick={this.getValveInfo}>读取
                                    </button>
                                </div>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-info "
                                            onClick={this.saveValveInfo}>设置
                                    </button>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div className="top-box" style={{marginTop:'0px'}}>
                        <h3><img
                            src="https://www.17sucai.com/preview/3250/2013-10-10/demo2/images/icon_22.png"
                            alt=""/>OTA设置</h3>
                        <div style={{display: 'flex',marginBottom:'10px'}}>
                            <div>
                                <div className={'marginTop15'}>
                                    <label style={{width: '150px'}}>OTA Server Host : </label>
                                    <Input style={{width: '270px'}} value={this.state.read21}
                                           onChange={(e) => {
                                               this.setState({
                                                   read21: e.target.value
                                               })
                                           }}/>
                                    <label style={{width: '120px'}}>OTA Server Port : </label>
                                    <Input style={{width: '270px'}} value={this.state.read22}
                                           onChange={(e) => {
                                               this.setState({
                                                   read22: e.target.value
                                               })
                                           }}/>
                                </div>
                            </div>
                            <div style={{flex: 1, marginLeft: '10px'}}>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-success "
                                            onClick={this.getOTAInfo}>读取
                                    </button>
                                </div>
                                <div className="form-group"
                                     style={{display: 'inline-block', marginBottom: '0', marginTop: '12px'}}>
                                    <button style={{width: '150px'}} id="read-meter-params" type="button"
                                            className="btn  btn-info "
                                            onClick={this.saveOTAInfo}>设置
                                    </button>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div className="table-box">
                        <table>
                            <tbody>
                            <tr className={'theader'}>
                                <td style={{textAlign:'left',paddingLeft:'30px'}}>应用配置</td>
                                <td>获取值</td>
                                <td>设置值</td>
                            </tr>
                            <tr>
                                <td colSpan={3}>
                                    NB
                                </td>
                            </tr>
                            <tr>
                                <td>PSM Peroidic (秒)</td>
                                <td>
                                    {this.state.read6}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={0} value={this.state.set.write6}
                                                 onChange={(e) => {
                                                     this.setStateDate('write6', e)
                                                 }}/></td>
                            </tr>
                            <tr>
                                <td>PSM Active (秒)</td>
                                <td>
                                    {this.state.read7}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={0} value={this.state.set.write7}
                                                 onChange={(e) => {
                                                     this.setStateDate('write7', e)
                                                 }}/></td>
                            </tr>
                            <tr>
                                <td>Request eDRX (秒)</td>
                                <td>
                                    {this.state.read8}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={0} value={this.state.set.write8}
                                                 onChange={(e) => {
                                                     this.setStateDate('write8', e)
                                                 }}/></td>
                            </tr>
                            <tr>
                                <td colSpan={3}>
                                    Onenet Client
                                </td>
                            </tr>
                            <tr>
                                <td>Onenet Login Timeout (30-360秒)</td>
                                <td>
                                    {this.state.read9}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={30} max={360}
                                                 value={this.state.set.write9} onChange={(e) => {
                                    this.setStateDate('write9', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Login Max Retry (1-100)</td>
                                <td>
                                    {this.state.read10}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={1} max={100}
                                                 value={this.state.set.write10} onChange={(e) => {
                                    this.setStateDate('write10', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Lifetime (30-86400秒)</td>
                                <td>
                                    {this.state.read11}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={30} max={86400}
                                                 value={this.state.set.write11} onChange={(e) => {
                                    this.setStateDate('write11', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Lifetime over (30-86400秒)</td>
                                <td>
                                    {this.state.read12}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={30} max={86400}
                                                 value={this.state.set.write12} onChange={(e) => {
                                    this.setStateDate('write12', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Lifetime update (30-86400秒)</td>
                                <td>
                                    {this.state.read13}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={30} max={86400}
                                                 value={this.state.set.write13} onChange={(e) => {
                                    this.setStateDate('write13', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Lifetime update timeout (10-120秒)</td>
                                <td>
                                    {this.state.read14}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={10} max={120}
                                                 value={this.state.set.write14} onChange={(e) => {
                                    this.setStateDate('write14', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Notify timeout (10-120秒)</td>
                                <td>
                                    {this.state.read15}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={10} max={120}
                                                 value={this.state.set.write15} onChange={(e) => {
                                    this.setStateDate('write15', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Notify Max Retry(1-100)</td>
                                <td>
                                    {this.state.read16}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={1} max={100}
                                                 value={this.state.set.write16} onChange={(e) => {
                                    this.setStateDate('write16', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Onenet Notify Failed (10-100)</td>
                                <td>
                                    {this.state.read17}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={10} max={100}
                                                 value={this.state.set.write17} onChange={(e) => {
                                    this.setStateDate('write17', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td colSpan={3}>
                                    Misc
                                </td>
                            </tr>
                            <tr>
                                <td>Onenet Observe (60-300秒)</td>
                                <td>
                                    {this.state.read18}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={60} max={300}
                                                 value={this.state.set.write18} onChange={(e) => {
                                    this.setStateDate('write18', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>Network Attach timeout (3600-86400秒)</td>
                                <td>
                                    {this.state.read19}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={3600} max={86400}
                                                 value={this.state.set.write19} onChange={(e) => {
                                    this.setStateDate('write19', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td>NTP Cycle (300-86400秒)</td>
                                <td>
                                    {this.state.read20}
                                </td>
                                <td><InputNumber style={{width: '100%'}} min={300} max={86400}
                                                 value={this.state.set.write20} onChange={(e) => {
                                    this.setStateDate('write20', e)
                                }}/></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <button  id="read-meter-params" type="button"
                                            className="btn  btn-success  "
                                            onClick={this.getOption1}>读取
                                    </button>
                                    <button  id="read-meter-params" type="button"
                                            className="btn  btn-info  "
                                            onClick={this.exportGet}>导出获取值
                                    </button>
                                </td>
                                <td>

                                    <button  id="write-meter-params" type="button"
                                            className="btn     btn-warning "
                                            onClick={this.importSet}>导入设置值
                                    </button>
                                    <button  id="write-meter-params" type="button"
                                            className="btn  btn-success  "
                                            onClick={this.saveInfo}>写入
                                    </button>
                                    <button  id="write-meter-params" type="button"
                                            className="btn  btn-info  "
                                            onClick={this.exportSet}>导出设置值
                                    </button>
                                    <button  id="read-meter-params" type="button"
                                             className="btn  btn-danger  "
                                             onClick={this.reset}>恢复默认设置
                                    </button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    {/* <div className="btn-around">
                        <div className="form-around-btn">

                        </div>
                    </div>*/}
                    {/*   <div className="main-box">
                        <div className="left">
                            <h3><img src="https://www.17sucai.com/preview/3250/2013-10-10/demo2/images/icon_22.png" alt=""/>读取RTU参数</h3>
                            <div className="form-around">

                                <div className="form-around-label">
                                    <div>
                                        <label>PSM Peroidic (秒) : </label>
                                    </div>
                                    <div>
                                        <label>PSM Active (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Request eDRX (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Login Timeout (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Login Max Retry: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime  (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime over (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime update: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime update timeout (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify timeout (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify Max Retry: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify Failed: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Observe (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Network Attach timeout (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>NTP Cycle (秒) :  </label>
                                    </div>
                                </div>
                                <div className="form-around-input">
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read6} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read7} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read8} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read9} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read10} readOnly className="form-control"/>
                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read11} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read12} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read13} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read14} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read15} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read16} readOnly className="form-control"/>
                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read17} readOnly className="form-control"/>
                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read18} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read19} readOnly className="form-control"/>

                                    </div>
                                    <div className="form-group  input-group">
                                        <input type="text" value={this.state.read20} readOnly className="form-control"/>

                                    </div>

                                       <div className="form-group  input-group" style={{display:'flex'}}>
                                        <input type="text"  value={this.state.pc1} onChange={(e)=>{
                                            this.setStateDate('pc1',e)
                                        }} style={{width:'100px'}} className="form-control" />
                                        <input type="text"  value={this.state.pc2} onChange={(e)=>{
                                            this.setStateDate('pc2',e)
                                        }} style={{flex:1,marginLeft:'5px'}} className="form-control" />
                                        <input type="text"  value={this.state.pc3} onChange={(e)=>{
                                            this.setStateDate('pc3',e)
                                        }} style={{flex:1,marginLeft:'5px'}} className="form-control" />
                                    </div>
                                </div>
                            </div>
                            <div className="btn-around">
                                <div className="form-around-btn">
                                    <button style={{marginTop: '15px'}} id="read-meter-params" type="button"
                                            className="btn  btn-success  btn-block"
                                            onClick={this.getOption1}>读取
                                    </button>
                                    <button style={{marginTop: '15px'}} id="read-meter-params" type="button"
                                            className="btn  btn-info  btn-block"
                                            onClick={this.export}>导出
                                    </button>
                                    <button style={{marginTop: '15px'}} id="read-meter-params" type="button"
                                            className="btn  btn-danger  btn-block"
                                            onClick={this.reset}>恢复默认设置
                                    </button>

                                </div>
                            </div>
                        </div>
                        <div className="right">
                            <h3><img src="https://www.17sucai.com/preview/3250/2013-10-10/demo2/images/icon_5.png" alt=""/>设置RTU参数</h3>
                            <div className="form-around">

                                <div className="form-around-label">
                                    <div>
                                        <label>PSM Peroidic (秒) : </label>
                                    </div>
                                    <div>
                                        <label>PSM Active (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Request eDRX (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Login Timeout (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Login Max Retry: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime  (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime over (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime update: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Lifetime update timeout (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify timeout (秒) : </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify Max Retry: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Notify Failed: </label>
                                    </div>
                                    <div>
                                        <label>Onenet Observe (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>Network Attach timeout (秒) :  </label>
                                    </div>
                                    <div>
                                        <label>NTP Cycle (秒) :  </label>
                                    </div>
                                </div>
                                <div className="form-around-input">
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write6} onChange={(e) => {
                                            this.setStateDate('write6', e)
                                        }} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write7} onChange={(e) => {
                                            this.setStateDate('write7', e)
                                        }} />


                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write8} onChange={(e) => {
                                            this.setStateDate('write8', e)
                                        }} />


                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}}  value={this.state.set.write9||''} onChange={(e) => {
                                            this.setStateDate('write9', e)
                                        }}  min={30} max={360} placeholder={'30-360'} />


                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write10} onChange={(e) => {
                                            this.setStateDate('write10', e)
                                        }} min={1} max={100} placeholder={'1-100'} />
                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write11} onChange={(e) => {
                                            this.setStateDate('write11', e)
                                        }} min={30} max={86400} placeholder={'30-86400'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write12} onChange={(e) => {
                                            this.setStateDate('write12', e)
                                        }} min={30} max={86400} placeholder={'30-86400'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write13} onChange={(e) => {
                                            this.setStateDate('write13', e)
                                        }} min={30} max={86400} placeholder={'30-86400'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write14} onChange={(e) => {
                                            this.setStateDate('write14', e)
                                        }} min={10} max={120} placeholder={'10-120'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write15} onChange={(e) => {
                                            this.setStateDate('write15', e)
                                        }} min={10} max={120} placeholder={'10-120'}  />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write16} onChange={(e) => {
                                            this.setStateDate('write16', e)
                                        }}  min={10} max={100} placeholder={'10-100'} />
                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write17} onChange={(e) => {
                                            this.setStateDate('write17', e)
                                        }} min={10} max={100} placeholder={'10-100'}  />
                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write18} onChange={(e) => {
                                            this.setStateDate('write18', e)
                                        }} min={60} max={300} placeholder={'60-300'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write19} onChange={(e) => {
                                            this.setStateDate('write19', e)
                                        }} min={30} max={86400} placeholder={'30-86400'} />

                                    </div>
                                    <div className="form-group  input-group">
                                        <InputNumber style={{width:'100%'}} value={this.state.set.write20} onChange={(e) => {
                                            this.setStateDate('write20', e)
                                        }}  min={30} max={86400} placeholder={'30-86400'} />

                                    </div>

                                       <div className="form-group  input-group" style={{display:'flex'}}>
                                        <input type="text"  value={this.state.set.pc1} onChange={(e)=>{
                                            this.setStateDate('pc1',e)
                                        }} style={{width:'100px'}}  />
                                        <input type="text"  value={this.state.set.pc2} onChange={(e)=>{
                                            this.setStateDate('pc2',e)
                                        }} style={{flex:1,marginLeft:'5px'}}  />
                                        <input type="text"  value={this.state.set.pc3} onChange={(e)=>{
                                            this.setStateDate('pc3',e)
                                        }} style={{flex:1,marginLeft:'5px'}}  />
                                    </div>
                                </div>
                            </div>
                            <div className="btn-around">
                                <div className="form-around-btn">
                                    <button style={{marginTop: '15px'}} id="write-meter-params" type="button"
                                            className="btn  btn-success  btn-block"
                                            onClick={this.saveInfo}>写入
                                    </button>
                                    <button style={{marginTop: '15px'}} id="write-meter-params" type="button"
                                            className="btn  btn-info  btn-block"
                                            onClick={this.saveInfo}>导出
                                    </button>
                                </div>
                            </div>
                        </div>


                    </div>*/}
                    <div className="project-bottom">


                    </div>
                </div>
                <Modal
                    title={'打印 IMEI'}
                    visible={this.state.printModal}
                    footer={null}
                    width={600}
                    centered={true}
                    onCancel={()=>{
                        this.setState({
                            printModal:false
                        })
                    }}
                >
                    <div style={{textAlign:'center'}}>
                        <button style={{width: '150px',marginRight:"16px"}} type="button"
                                className="btn  btn-success "
                                onClick={()=>{
                                    this.print0('IOT-4G')
                                }}>IOT-4G
                        </button>
                        <button style={{width: '150px'}}  type="button"
                                className="btn  btn-info "
                                onClick={()=>{
                                    this.print0('IOT-NB')
                                }}>IOT-NB
                        </button>
                    </div>

                </Modal>
            </div>

        );
    }
}

export default App;
